package com.betterjr.modules.risk.api.service;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.utils.Collections3;
import com.betterjr.common.web.AbstarctRemoteApiInvoke;
import com.betterjr.common.web.AjaxRemoteApiParam;
import com.betterjr.modules.contract.IContractStamperService;

/**
 * 
 * @ClassName: RemoteApiQueryOwnStamperInvokeService 
 * @Description: 查询电子印章api类
 * @author xuyp
 * @date 2018年7月6日 下午8:06:56 
 *
 */
@Service
public class RemoteApiQueryOwnStamperInvokeService extends AbstarctRemoteApiInvoke {

    @Reference(interfaceClass = IContractStamperService.class)
    private IContractStamperService contractStamperService;

    private String apiCode = "RAI00002";

    @Override
    public String saveOrFindInvoke(AjaxRemoteApiParam param) {

        return contractStamperService.webQueryOwnStamper(findProperties(param.getParamMap(), "custNo", Long.class),
                findProperties(param.getParamMap(), "flag", Integer.class),
                findProperties(param.getParamMap(), "pageNum", Integer.class),
                findProperties(param.getParamMap(), "pageSize", Integer.class));
    }

    @Override
    public boolean supportInvoke(String anApiCode) {

        return apiCode.equals(anApiCode);
    }

    @Override
    public boolean checkParam(Map<String, Object> anParamMap) {

        boolean flag = true;

        if (flag && Collections3.isEmpty(anParamMap)) flag = false;

        if (flag && !anParamMap.containsKey("custNo")) flag = false;
        if (flag && !anParamMap.containsKey("flag")) flag = false;
        if (flag && !anParamMap.containsKey("pageNum")) flag = false;
        if (flag && !anParamMap.containsKey("pageSize")) flag = false;

        return flag;
    }

}
